/**
 * 
 */
package com.acme.bankapp.domain.client;

import com.acme.bankapp.domain.account.Account;

/**
 * @author Labun Konstantin
 * 
 */
public class Client {

	private Account account;

	private final Gender gender;

	private String name;

	/**
	 * @param account
	 * @param name
	 */
	public Client(String name, Gender gender, Account account) {
		super();
		this.account = account;
		this.name = name;
		this.gender = gender;
	}

	/**
	 * @return the account
	 */
	public Account getAccount() {
		return account;
	}

	public String getClientSalutation() {
		return gender + getName();
	}

	/**
	 * @return the gender
	 */
	public Gender getGender() {
		return gender;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return getClientSalutation();
	}

	@Override
	public int hashCode() {
	    final int prime = 31;
	    int result = 1;
	    result = prime * result
		    + ((account == null) ? 0 : account.hashCode());
	    result = prime * result
		    + ((gender == null) ? 0 : gender.hashCode());
	    result = prime * result + ((name == null) ? 0 : name.hashCode());
	    return result;
	}

	@Override
	public boolean equals(Object obj) {
	    if (this == obj)
		return true;
	    if (obj == null)
		return false;
	    if (getClass() != obj.getClass())
		return false;
	    Client other = (Client) obj;
	    if (account == null) {
		if (other.account != null)
		    return false;
	    } else if (!account.equals(other.account))
		return false;
	    if (gender != other.gender)
		return false;
	    if (name == null) {
		if (other.name != null)
		    return false;
	    } else if (!name.equals(other.name))
		return false;
	    return true;
	}
	
}
